import { http } from '@/utils/request';
import type { PayStatus, PayMethod, PaymentRecord, WxPayParams, AliPayParams, RefundParams, PayResult } from './types';

// 创建支付宝支付
export function createAliPay(params: AliPayParams) {
    return http.post('/payment/api/payment/ali/create', params);
}

// 创建微信小程序支付
export function createWxPay(params: WxPayParams) {
    return http.post('/payment/api/payment/wx/mini/create', params);
}

// 创建余额支付
export function createBalancePay(params: WxPayParams) {
    return http.post('/payment/api/payment/balance/create', params);
}

// 查询支付宝支付状态
export function queryAliPayStatus(orderNo: string,type:string) {
    return http.get(`/payment/api/payment/ali/query/${orderNo}/type=${type}`);
}

// 查询微信支付状态
export function queryWxPayStatus(payNo: string,type:string) {
    return http.get(`/payment/api/payment/wx/query/${payNo}/type=${type}`);
}

// 关闭支付宝支付订单
export function closeAliPay(orderNo: string) {
    return http.post(`/payment/api/payment/ali/close/${orderNo}`);
}

// 关闭微信支付订单
export function closeWxPay(payNo: string) {
    return http.post(`/payment/api/payment/wx/close/${payNo}`);
}

// 申请支付宝退款
export function refundAliPay(params: RefundParams) {
    return http.post(`/payment/api/payment/ali/refund/${params.orderNo}`, {
        reason: params.reason
    });
}

// 申请微信支付退款
export function refundWxPay(payNo: string, reason: string) {
    return http.post(`/payment/api/payment/wx/refund/${payNo}`, {
        reason
    });
}
